// 用户管理相关API
window.userAPI = {
    // 获取用户列表
    getUsers: async (params = {}) => {
        try {
            const response = await apiClient.get('/api/users/', { params });
            return response;
        } catch (error) {
            console.error('获取用户列表失败:', error);
            throw error;
        }
    },
    
    // 获取用户详情
    getUser: async (id) => {
        try {
            const response = await apiClient.get(`/api/users/${id}`);
            return response;
        } catch (error) {
            console.error('获取用户详情失败:', error);
            throw error;
        }
    },
    
    // 创建用户
    createUser: async (data) => {
        try {
            const response = await apiClient.post('/api/users', data);
            return response;
        } catch (error) {
            console.error('创建用户失败:', error);
            throw error;
        }
    },
    
    // 更新用户
    updateUser: async (id, data) => {
        try {
            const response = await apiClient.put(`/api/users/${id}`, data);
            return response;
        } catch (error) {
            console.error('更新用户失败:', error);
            throw error;
        }
    },
    
    // 删除用户
    deleteUser: async (id) => {
        try {
            const response = await apiClient.delete(`/api/users/${id}`);
            return response;
        } catch (error) {
            console.error('删除用户失败:', error);
            throw error;
        }
    },
    
    // 重置用户密码
    resetPassword: async (id, newPassword) => {
        try {
            const response = await apiClient.post(`/api/users/${id}/reset-password`, { password: newPassword });
            return response;
        } catch (error) {
            console.error('重置密码失败:', error);
            throw error;
        }
    }
};
